function countTriplets(nums: number[]): number {
    const map = new Map();
    for (const x of nums) {
        for (const y of nums) {
            const z = x & y;
            map.set(z, (map.get(z) || 0) + 1);
        }
    }

    let ans = 0;
    for (const x of nums) {
        // @ts-ignore
        for (const [y, c] of map) {
            if (!(x & y)) ans += c;
        }
    }

    return ans;
}

// 没有运行按钮！！
/*
let nums: number[] = [2,1,3];
    console.log(countTriplets(nums));

    nums = [0,0,0];
    console.log(countTriplets(nums));
* */


// 没有运行按钮！！
// let readLine = require("readline");
// const rl = readLine.createInterface({
//     input: process.stdin,
//     output: process.stdout
// });
//
// rl.on(function () {
//     let nums: number[] = [2,1,3];
//     console.log(countTriplets(nums));
//
//     nums = [0,0,0];
//     console.log(countTriplets(nums));
// })